package com.chc.web.bookcase.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chc.web.book.entity.Book;
import com.chc.web.book.entity.BookParm;
import com.chc.web.bookcase.entity.BookCase;
import com.chc.web.bookcase.mapper.BookCaseMapper;
import com.chc.web.bookcase.service.BookCaseService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/04/21/17:28
 * @Description:
 */
@Service
public class BookCaseServiceImpl extends ServiceImpl<BookCaseMapper, BookCase> implements BookCaseService {
    @Override
    public IPage<BookCase> list(BookParm parm) {
        QueryWrapper<BookCase> query = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(parm.getName())){
            query.lambda().eq(BookCase::getName,parm.getName());
        }
        //构造分页条件
        IPage<BookCase> page = new Page<>();
        page.setCurrent(parm.getCurrentPage());
        page.setSize(parm.getPageSize());
        return this.baseMapper.selectPage(page,query);
    }
}
